<template>
    <MyTable :loading="queryLoading" :cols="cols" :data="list">
      <template v-slot:level="{row:{level}}">
          <el-tag :type="colors[level]">
              {{levels[level]}}级
          </el-tag>
      </template>
    </MyTable>
</template>

<script>
import { getRightsList } from '@/api/rights'
    export default {
        name:"rightsList",
        data() {
            return {
              /**
               * 等级
               */
              levels:["一","二","三"],
              colors:["","success","warning"],
             /**
              * 列
              */
              cols: [
                {
                  title:"#",
                  type:"index",
                },
                {
                  title:"权限名称",
                  name:"authName",
                },
                {
                  title:"路径",
                  name:"path",
                },
                {
                  title:"权限管理",
                  slot:"level",
                },
              ],
            }
          },
          created () {
            this.getRights();
          },
        methods: {
          /**
           * 获取权限列表
           */
          async getRights() {
             try {
              this.queryLoading=true;
              this.list=await getRightsList();
             } catch (error) {
              console.log(error);
             }
              this.queryLoading=false;
          }
        },
    }
</script>

<style lang="scss" scoped>

</style>